const express = require('express');
const router = express.Router();
const AuthController = require('../controllers/auth.controller');
const { registerValidation, loginValidation, validate } = require('../middlewares/validator.middleware');
const authMiddleware = require('../middlewares/auth.middleware');
const upload = require('../middlewares/upload.middleware');

// 注册路由
router.post('/register', registerValidation, validate, AuthController.register);

// 登录路由
router.post('/login', loginValidation, validate, AuthController.login);

// 获取用户信息路由
router.get('/userinfo', authMiddleware, AuthController.getUserInfo);

// 添加更新个人资料路由
router.put('/profile', authMiddleware, AuthController.updateProfile);

// 添加头像上传路由
router.post('/upload-avatar', 
    authMiddleware, 
    upload.single('avatar'), // 'avatar' 是文件字段名
    AuthController.uploadAvatar
);

module.exports = router; 